import pygame
import sys
import GUI

pygame.init()

screen = pygame.display.set_mode((300, 400))

save = {
	'money': 0,
	'click': 1,
	'upgrade': {
		1: 10
	} 
}

i = []

i.append(GUI.Button(screen, text = 'CLICK', width = 300, height = 200, x = 0, y = 200, hover_color = (255, 255, 200))) # 0
i.append(GUI.Button(screen, text = '', width = 300, height = 50, bg_color = (200, 200, 200), hover_color = (200, 200, 200))) # 1
i[1].set_text(str(save['money']) + ' COIN')
i.append(GUI.Button(screen, text = '', width = 150, height = 150, x = 0, y = 50, bg_color = (255, 150, 150))) # 2
i.append(GUI.Button(screen, text = 'CLICK: 1', width = 150, height = 150, x = 150, y = 50, bg_color = (150, 225, 150))) # 3
i[3].set_text('CLICK: '+str(save['click']))
i[2].set_text('UP: '+str(save['upgrade'][1])+' COIN')
while True:

	for value in range(len(i)):
		i[value].update()

	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			sys.exit()

		elif event.type == pygame.MOUSEBUTTONDOWN:

			if i[0].active(key = event.button):
				save['money'] += save['click']
				i[1].set_text(str(save['money']) + ' COIN')
			elif i[2].active(key = event.button):
				if save['upgrade'][1] <= save['money']:
					save['money'] -= save['upgrade'][1]
					save['click'] += 1
					i[1].set_text(str(save['money']))
					i[3].set_text('CLICK: '+str(save['click']))

	pygame.display.update()